package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbExit;
import com.ruoyi.wb.service.IWbExitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 疏散通道Controller
 *
 * @author ruoyi
 * @date 2024-10-14
 */
@Api(tags="疏散通道管理")
@RestController
@RequestMapping("/wb/wbExit")
public class WbExitController extends BaseController {
    @Autowired
    private IWbExitService wbExitService;

    /**
     * 查询疏散通道列表
     */
    @ApiOperation("查询疏散通道列表")
    @GetMapping("/list")
    public TableDataInfo list(WbExit wbExit) {
        List<WbExit> list = wbExitService.selectWbExitList(wbExit);
        return getDataTable(list);
    }

    /**
     * 导出疏散通道列表
     */
    @ApiOperation("导出疏散通道列表")
    @Log(title = "疏散通道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbExit wbExit) {
        List<WbExit> list = wbExitService.selectWbExitList(wbExit);
        ExcelUtil<WbExit> util = new ExcelUtil<WbExit>(WbExit.class);
        util.exportExcel(response, list, "疏散通道数据");
    }

    /**
     * 获取疏散通道详细信息
     */
    @ApiOperation("获取疏散通道详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wbExitService.selectWbExitById(id));
    }

    /**
     * 新增疏散通道
     */
    @ApiOperation("新增疏散通道")
    @Log(title = "疏散通道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbExit wbExit) {
        return toAjax(wbExitService.insertWbExit(wbExit));
    }

    /**
     * 修改疏散通道
     */
    @ApiOperation("修改疏散通道")
    @Log(title = "疏散通道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbExit wbExit) {
        return toAjax(wbExitService.updateWbExit(wbExit));
    }

    /**
     * 删除疏散通道
     */
    @ApiOperation("删除疏散通道")
    @Log(title = "疏散通道", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wbExitService.deleteWbExitByIds(ids));
    }
}